import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)
/* eslint-disable */ // 忽略该行往下 eslint的错误

const routes = [
  {
    path: '/',
    name: 'Home',
    redirect:'/home'//路由重定向
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    // children:[// 路由嵌套
    //   {path:'detail/:id',
    //   name:'Detail',
    //   props: true, 
    //   component: () => import(/* webpackChunkName: "about" */ '../views/Detail.vue')
    //   }
    // ]
  },
  {
    path: '/fenlei',
    name: 'Fenlei',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Fenlei.vue')
  },
  {
    // params 传参
    path: '/detail/:id',
    name: 'Detail',
    props: true, // 组件可以使用props 接受参数
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Detail.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
